package service

import (
	"errors"
	"ginfast/api/weixin/dto"
	"ginfast/api/weixin/model"
	"ginfast/pkg/dao"
	"ginfast/util"
)

type config struct {
}

var Config config

// AppConfig 获取小程序配置参数
func (config) App() (*dto.AppCfg, error) {
	var data model.Config
	if err := dao.DbFirstBy(&data, "name like ?", dto.AppCfgName); err != nil {
		return nil, errors.New("please set app information firstly")
	}
	var config dto.AppCfg
	util.StringToJSON(data.Value, &config)
	return &config, nil
}
